﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLKhachSan.DTO;
using System.Data;
using System.Data.SqlClient;

namespace QLKhachSan.DAO
{
    public class DAO_NhanVien
    {
        public static void themNhanVien(DTO_NhanVien p)
        {
            string[] name = new string[7] { "@TenNV","@GioiTinh","@CMND","@NgaySinh","@DiaChi","@SDT","@NgayVaoLam" };
            object[] ob = new object[7] { p.TenNV,p.GioiTinh,p.CMND,p.NgaySinh,p.DiaChi,p.SDT,p.NgayVaoLam };
            clsKetNoi.ThucThiLenhCoTS("pr_ThemNhanVien", name, ob, 7);
        }
        public static DataTable hienthiDanhSachNhanVien()
        {
            return clsKetNoi.Load("pr_HienThiNhanVien");
        }
        public static void suaNhanVien(DTO_NhanVien p)
        {
            string[] name = new string[8] { "@MaNV","@TenNV", "@GioiTinh", "@CMND", "@NgaySinh", "@DiaChi", "@SDT", "@NgayVaoLam" };
            object[] ob = new object[8] { p.MaNV,p.TenNV, p.GioiTinh, p.CMND, p.NgaySinh, p.DiaChi, p.SDT, p.NgayVaoLam };
            clsKetNoi.ThucThiLenhCoTS("pr_SuaNhanVien", name, ob, 8);
        }
        public static void xoaNhanVien(DTO_NhanVien p)
        {
            string[] name = new string[1] { "@MaNV" };
            object[] ob = new object[1] { p.MaNV };
            clsKetNoi.ThucThiLenhCoTS("pr_XoaNhanVien", name, ob, 1);
        }
        public static DataTable timNhanVienTheoNgayVaoLam(DateTime tungay,DateTime denngay)
        {
            string[] name = new string[2] { "@tungay", "@denngay" };
            object[] ob = new object[2] { tungay,denngay };
            return clsKetNoi.LoadCoTS("pr_HienThiNhanVienKhoangNgayVaoLam", name, ob, 2);
        }
       
        public static DataTable hienthiDanhSachNhanVienTheoMaNV(int maNV)
        {
            string[] name = new string[1] { "@MaNV" };
            object[] ob = new object[1] { maNV };
            return clsKetNoi.LoadCoTS("pr_HienThiNhanVienTheoMaNV",name,ob,1);
        }
        
    }
}
